package reflect;

import java.lang.reflect.Method;
import java.lang.reflect.Modifier;

public class ReflectDemo4 {
    public static void main(String[] args) throws ClassNotFoundException {
        Class cls =Class.forName("reflect.Person");
        Method[] methods = cls.getDeclaredMethods();
        for (Method method : methods){
            System.out.println(method.getName());
            int count =method.getParameterCount();
            System.out.println("共" + count + "个参数");
        int modifiers = method.getModifiers();
        switch (modifiers){
            case Modifier.PUBLIC:
                System.out.println("公开方法");
                break;
            case Modifier.PRIVATE:
                System.out.println("私有方法");
                break;
            case Modifier.PROTECTED:
                System.out.println("受保护的方法");
                break;
        }
        }
    }
}
